function isPerfectSquare(num: number): boolean {
    if(num === 0 || num ===1){
        return true;
    }
    let left:number = 1;
    let right:number = num;
    while(left<=right){
        let mid:number = Math.floor((left+right)/2)
        if(mid*mid === num){
            return true;
        }else if(mid*mid < num){
            left = mid+1;
        }else {
            right = mid -1;
        }
    }
    return false;
};

function isPerfectSquare(num: number): boolean {
    if(num === 0 || num ===1){
        return true;
    }
    let r0:number = num;
    while(r0*r0 > num){
        r0 = Math.floor((r0 + num/r0)/2)
        console.log(r0)
    }
    return r0*r0 === num;
};